/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.ues21.tcs.ecommerce2011.mvc.service.impl;

import edu.ues21.tcs.ecommerce2011.mvc.dao.ArticuloDAO;
import edu.ues21.tcs.ecommerce2011.mvc.dao.MarcaDAO;
import edu.ues21.tcs.ecommerce2011.mvc.model.Articulo;
import edu.ues21.tcs.ecommerce2011.mvc.model.Marca;
import edu.ues21.tcs.ecommerce2011.mvc.service.CatalogoService;
import java.util.List;

/**
 *
 * @author vascordoba
 */
public class CatalogoServiceImpl implements CatalogoService {

    private ArticuloDAO artDao;
    private MarcaDAO marDao;

    public CatalogoServiceImpl(ArticuloDAO artDao,MarcaDAO marDao){
        this.artDao=artDao;
        this.marDao=marDao;
    }

    @Override
    public List<Articulo> buscar(String buscar) throws Exception {
        return artDao.search(buscar);
    }

    @Override
    public List<Articulo> getArticulos(Integer marcaId) throws Exception{
        if(marcaId==null || marcaId.intValue()==0){
            return artDao.getAll();
        }
        else{
            return artDao.getAll(marcaId);
        }
    }

    @Override
    public List<Marca> getMarcas() throws Exception {
        return marDao.getAll();
    }

}
